package cn.slg.module.system.service.wujiang;

import cn.slg.module.system.dal.dataobject.wujiang.WuJiangDO;
import cn.slg.module.system.dal.mysql.wujiang.WuJiangMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service("wuJiangService")
public class WuJiangServiceImpl implements WuJiangService {

    @Resource
    private WuJiangMapper wuJiangMapper;

    @Override
    public List<WuJiangDO> getAllWuJiang() {
        List<WuJiangDO> wuJiangDOS = wuJiangMapper.selectList(new LambdaQueryWrapper<>());

        return wuJiangDOS;
    }

    @Override
    public Map<Integer, WuJiangDO> getWuJiangMapByIds(List<Integer> ids) {

        List<WuJiangDO> wuJiangDOS = wuJiangMapper.selectList(new LambdaQueryWrapper<WuJiangDO>().in(WuJiangDO::getId, ids));

        return wuJiangDOS.stream().collect(Collectors.toMap(WuJiangDO::getId, wuJiangDO -> wuJiangDO));
    }

    @Override
    public List<WuJiangDO> getWuJiangByIds(List<Integer> ids) {

        return wuJiangMapper.selectList(new LambdaQueryWrapper<WuJiangDO>().in(WuJiangDO::getId, ids));
    }
}
